import React, { Children } from "react";
import { useRoutes, RouteObject, Navigate } from "react-router-dom";

import Login from "pages/unAuthApp/Login";
import Register from "pages/unAuthApp/Register";
import { ProjectList } from "pages/project-list";
import { Project } from "pages/project";
import { Epic } from "pages/epic";
import { Kanban } from "pages/kanban";
import { Main } from "pages/Main";

const Router: React.FC = () => {
  const routes: RouteObject[] = [
    {
      path: "projects",
      element: <Main/>,
      children: [
        {
          // 项目列表
          path: "",
          element: <ProjectList />,
        },
        {
          // 项目详情页
          path: ":id",
          element: <Project />,
          children: [
            {
              // 看板
              path: "kanban",
              element: <Kanban />,
            },
            {
              // 任务组
              path: "epic",
              element: <Epic />,
            },
          ],
        },
      ]
    },
    {
      path: "login",
      element: <Login />,
    },
    {
      path: "register",
      element: <Register />,
    },
    {
      path: "*",
      element: <Navigate to="/projects" />,
    },
  ];
  return useRoutes(routes);
};

export default Router;
